var parentwin = new Array()

function showwin(winID, winSrc, winTitle, winWidth, winHeight,win) {  //创建模式窗口
    parentwin[winID] = win;

    layer.open({
        id: winID,
        type: 2,
        title: winTitle,
        shadeClose: false,
        shade: 0.5,
        fixed: false, //不固定
        maxmin: false, //开启最大化最小化按钮
        area: [winWidth + "px", winHeight + "px"],
        end: function () {
            parentwin[winID] = null;
        },
        content: winSrc

    });
}

function closewin(winname) {  //关闭窗口
    winname = (winname == null) ? "" : winname;
    parentwin[winname] = null;
    layer.close(winname);
}

function getparentwin(winname) { //获取父窗口
    winname = (winname == null) ? "" : winname;
    return parentwin[winname];
}

function getchildframe(winname) { //获取iframe
    winname = (winname == null) ? "" : winname;
    return $(window.frames[winname].document);
}

function getchildobject(winname, childID) { //获取iframe中子元素对象
    winname = (winname == null) ? "" : winname;
    return $("#" + childID, document.frames(winname).document);
}



function loading(isshow) {
    if ($("#loading").css("display") == null) {
        var divload = '';
        divload += '<div id="loading" style="display: none; position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 9001; background: #000 url(images/load.gif) no-repeat center; opacity: 0.5; filter: alpha(opacity=50); font-size: 14px; line-height: 20px;">';
        divload += '</div>';
        //        divload += '<div id="loading" style="display: none; width: 95px; height:96px; left: 46%; top:40%; z-index: 9002;opacity: 0.4;filter: alpha(opacity=80);position: absolute;background:url(images/load.gif) #fff">';
        //        divload += '</div>';
        divload += '<div id="loadingword" style="display: none;color: #fff;z-index: 9002; position: absolute; top: 59%; left: 44%;font-weight:bold;font-size:16px  " >';
        divload += '正在处理，请稍等。。。</div>';
        divload += '<div id="loadinglist"  style="z-index: 9000; width: 100%; height: 100%;background: none repeat scroll 0 0 #CCCCCC;left: 0;opacity: 0.1;filter: alpha(opacity=1);overflow: hidden; position: absolute;top: 0;">';
        divload += '<iframe width="100%" scrolling="no" height="100%" frameborder="0"></iframe></div>';
        $(document.body).append(divload);
    }
    if (isshow == true) {
        $("#loading").css("display", "block");
        $("#loadinglist").css("display", "block");
        $("#loadingword").css("display", "block");
    }
    else {
        $("#loading").css("display", "none");
        $("#loadinglist").css("display", "none");
        $("#loadingword").css("display", "none");
    }
}

function show(msg) {
    layer.alert(msg);
    return false;
}
function msg(msg) {
    layer.msg(msg);
    return false;
}
var showclosetime;
function showclose(res) {
    if (res == null)
        showclosetime = setTimeout("showcolse()", 1000);
    else
        showclosetime = setTimeout("showcolse()", res);
}
function showcolse() {
    layer.closeAll('dialog');
    clearTimeout(showclosetime);
}
function showerror(msg) {
    var data = JSON.parse(msg);
    msg = data.Message.replace("\r\n", "").replace("\r", "").replace("\n", "");
    err = data.StackTrace.replace("\r\n", "").replace("\r", "").replace("\n", "");
    var width = 500;
    var height = 200;
    height += 7 * (err.length / 20);
    var html = "<div class='alertmsg' >" + msg + "</div><div class='showerrorlist'  >" + err + "</div>";
    layer.open({
        type: 1,
        title: "错误提示",
        shade: 0.8,
        maxmin: true, //开启最大化最小化按钮
        area: [width + "px", height + "px"],
        content: html
    });
}

function showconfirm(msg, fun, title) {
    layer.confirm(msg, { title: title }, function () {
        fun.callback();
        layer.closeAll('dialog');
    }, function () {
        return;
    });

}


